<?php

namespace app\admin\controller;

use think\facade\Db;
use think\facade\View;

class Appset extends Base
{
    function __construct()
    {
        parent::__construct();
    }

    public function index()
    {
        $id = input('id');
        $app_set = Db::name('app_set')->where('1=1')->find();
        if (IS_POST) {
            $post_data = input();
            $data = [];
            $data['appid'] = $post_data['appid'];
            $data['appsecret'] = $post_data['appsecret'];
            $data['androidurl'] = $post_data['androidurl'];
            $data['iosurl'] = $post_data['iosurl'];
            $data['create_time'] = time();
            $data['describe'] = $post_data['describe'];
            $data['edition_number'] = $post_data['edition_number'];
            $data['edition_name'] = $post_data['edition_name'];
            $data['edition_force'] = $post_data['edition_force'];
            if($id){
                $row = Db::name('app_set')->where(array('id' => $id))->update($data);
            }else{
                $row = Db::name('app_set')->insertGetId($data);
            }

            return json(['status'=>1,'msg'=>'修改成功','url'=>url('Appset/index')]);
        }
        View::assign('info', $app_set);
        return View::fetch();
    }
}